﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Evpo.ContactData.ViewModel;

namespace Evpo.ContactData.UI
{
    public partial class AddressEditForm : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                int otherResidentCount = 0;
                if (uiAddressEdit.AddressID.HasValue)
                {
                    List<ContactListItem> list
                        = uiAddressEdit.ViewModel.GetAddressResidents(
                            uiAddressEdit.AddressID.Value);

                    uiOtherResidents.DataSource = list;
                    otherResidentCount = list.Count;
                }
                
                if (otherResidentCount == 0)
                    uiNoOtherResidents.Visible = true;
                
                DataBind();
            }
        }
    }
}